import React, { Component } from 'react'
//导入connect
import { connect } from 'react-redux'
class ComA extends Component {
  handleClick = () => {
    // console.log(this.props, 'ComAProps')
    //发送action
    this.props.sendAction()
  }
  render() {
    return (
      <div>
        ComA
        <button onClick={this.handleClick}>+</button>
      </div>
    )
  }
}
//实现组件A的功能
const mapDispatchToProps = (dispatch) => {
  return {
    sendAction: () => {
      //利用dispatch发送一个action
      dispatch({
        type: 'add_action',
      })
    },
  }
}
//A组件是发送方 要实现第二个参数
export default connect(null, mapDispatchToProps)(ComA)
